-
Notifications
You must be signed in to change notification settings - Fork 57
Fix incorrect types #438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix incorrect types #438
Conversation
A zip code is not required by some countries, for example, Antarctica.
Add missing options for ICreateShipmentParameters
Justintime50
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for submitting this, we'll need a couple changes to be able to roll this in:
- Although zip codes are not required for some countries, our API does expect zip codes presently for addresses. You will want to work with our support team to determine what may need to go in the zip code field for countries that don't support it. As such, we cannot accept the nulling of the zip fields on the address object as it would not be a correct change to make.
- With TaxIdentifier being a top-level object of our API, it would be better to place the type inside of its own folder structure like the other type objects are and follow the convention for defining it (with documenting the params as well like other objects).
If you'd rather not make these adjustments, let us know and we can continue the work you've started. Service and tax identifiers will be great additions that were previously missed.
|
You can close this pull release, I'm just offering it as a suggestion. Both zip and country are optional in IAddressCreateParameters according to the actual way the API works: the API will correctly return an error but the API does technically accept a blank value. The reason a zip ought to be optional: consider a new user-facing address form, all of those values would initially be blank. If my form object has a typescript type of IAddressCreateParameters, I'd have errors in my code since a zip code would initially be blank. Also we, know a street1 and a name are required to create a shipment, but having those values as optional seem to be correct way to handle the creation of a form object while the form is in the process of being filled out. The changes I submitted were necessary for my typescript to validate, so I'll just use my own fork of the project to facilitate the needs of my project. Thanks for looking at this! |
## Summary This PR addresses multiple critical issues with TypeScript definitions found during a comprehensive audit of the codebase. > NOTE: AI was used to generate these changes which would have been difficult to identify by hand. Closes #438 (partially) Closes #515 ## Fixes - Fixes #515 - ReferralCustomer type export issue - Property now correctly exported as `ReferralCustomer` (not `Referral`) to match JavaScript implementation - Added missing `api_keys` field to Referral interface ## Changes ### Critical Issues Fixed #### 1. Duplicate Rate Definitions - **Problem**: Two separate IRate interfaces in `types/Rate/Rate.d.ts` and `types/Shipment/Rate.d.ts` - **Fix**: Consolidated into single canonical definition, removed duplicate - **Files**: Deleted `types/Shipment/Rate.d.ts`, updated `types/Shipment/index.d.ts` to re-export from `../Rate` #### 2. Missing Exports Added missing exports to `types/index.d.ts`: - Referral - Claim - CustomerPortal - Embeddable - SmartRate - Luma #### 3. Missing Service Definitions Added missing services to EasyPost client (`types/EasyPost.d.ts`): - Luma - Claim - CustomerPortal (as CustomerPortalAccountLink) - Embeddable (as EmbeddablesSession) - SmartRate - ReferralCustomer (as Referral) ← **Fixes #515** #### 4. Missing Type Definitions - **Luma**: Created complete type definitions based on `src/services/luma_service.js` - `types/Luma/Luma.d.ts` - `types/Luma/index.d.ts` - **SmartRate**: Created missing `types/SmartRate/index.d.ts` - **TaxIdentifier**: Created `types/Shipment/TaxIdentifier.d.ts` for embedded tax identifier objects ### High Priority Fixes #### 5. Interface/Class Property Mismatches - **Pickup.instructions**: Made class property optional nullable to match interface - **Order**: Fixed `return_address`, `buyer_address`, `is_return` to be optional nullable - **User.reference**: Added missing field to IUser interface #### 6. Typos and Inconsistencies - **Options.d.ts**: Fixed typo `pickup_man_datetime` → `pickup_max_datetime` - **ScanForm.d.ts**: Standardized `getNextPage()` return type to use `scan_forms` - **Referral.d.ts**: Standardized `getNextPage()` return type to use `referral_customers` ## Testing - ✅ Build successful: `npm run build` - ✅ All tests passing: 173 tests across 34 test files - ✅ All new type files created correctly - ✅ Duplicate files removed successfully ## Files Changed **Modified (12)**: - types/EasyPost.d.ts - types/Order/Order.d.ts - types/Pickup/Pickup.d.ts - types/Referral/Referral.d.ts - types/ScanForm/ScanForm.d.ts - types/Shipment/Options/Options.d.ts - types/Shipment/Shipment.d.ts - types/Shipment/ShipmentCreateParameters.d.ts - types/Shipment/index.d.ts - types/User/User.d.ts - types/index.d.ts **Created (5)**: - types/Luma/Luma.d.ts - types/Luma/index.d.ts - types/SmartRate/index.d.ts - types/Shipment/TaxIdentifier.d.ts **Deleted (1)**: - types/Shipment/Rate.d.ts 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Sonnet 4.5 <[email protected]>
I made zip optional in IAddressCreateParameters since a zip code is not required in many countries. Also added optional service and tax_identifiers to IShipmentCreateParameteres to enable one-call buys.